﻿@using System.Linq
@using ShowPin.MvcPaging
@model IPagedList<ShowPin.MvcPaging.Demo.Models.Product>
@{
    ViewBag.Title = "带搜索参数的例子（二）";
}
<h2>根据分类浏览产品——根据多个产品分类搜索分页</h2>
@using (Html.BeginForm("PagingByCategories",

"Paging", FormMethod.Get))
{
		<p>选择产品分类</p>
		<ul>
			@{
    IEnumerable<string> selectedCategories = ViewBag.SelectedCategories ?? new string[0];
			}
			@foreach (var category in ViewBag.AllCategories)
   {
				<li>
					<label>
						<input type="checkbox" name="categories" value="@category" @if

(selectedCategories.Any(c => c == category))
                                                                 { <text> checked="checked"</text>} />
						@category
					</label>
				</li>
   }
		</ul>
		<input type="submit" value="提交" />
}
@if (Model.Source.Any())
{
    <table class="table">
        <thead>
            <tr>
                <th>产品名称</th>


                <th>分类名称</th>
            </tr>
        </thead>
        <tbody>


            @foreach (var product in Model.Source)
            {
                <tr>
                    <td>@product.Name</td>


                    <td>@product.Category</td>
                </tr>
            }
        </tbody>
    </table>
	@Html.Pager(Model.PageSize, Model.CurrentPage, Model.TotalItemCount).Options(o

=> o.HtmlAttributes(new { @class = "pagination pagination-large" }).RouteValues(new
{
    categories = ViewBag.SelectedCategories

}))
}
